package oa.hleast.xswl.controller.app;

import oa.hleast.xswl.pojo.domain.SysCommonConfig;
import oa.hleast.xswl.service.ISysCommonConfigService;
import oa.hleast.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;

/**
 * @author 209
 * @description
 * @date 2021/6/16
 */
@Api(tags = "【移动端】通用配置")
@RestController
@RequestMapping("/api.app/v1/commonConfig")
@AllArgsConstructor
@Slf4j
public class SysCommonConfigController {

    private final ISysCommonConfigService commonConfigService;

    @ApiOperation(value = "根据key获取系统配置-带缓存", httpMethod = "GET")
    @ApiImplicitParam(name = "configKey", value = "configKey", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class)
    @GetMapping("getByConfigKey")
    public Result<String> getByConfigKey(@RequestParam @NotBlank String configKey) {
        SysCommonConfig commonConfig = commonConfigService.getByConfigKey(configKey);
        return Result.success(commonConfig.getValue());
    }
}
